Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Deleting temp-table copies
When you pass a static temp-table from one procedure to another using the static
TABLEparameter form, either locally or remotely, Progress takes care of deleting the temp-table and its contents when the procedure that defines it is deleted, just as it does for other static objects.However, if you pass a temp-table through a
TABLE-HANDLE, then you are creating a dynamic copy of the temp-table. Whether there is a static temp-table definition for it on one side of the call or the other, theTABLE-HANDLEparameter creates a dynamic temp-table. If a procedure passes a temp-table to another procedure using theINPUT TABLE-HANDLEform, then the calling procedure must take responsibility for deleting the temp-table when it’s done with it. If a procedure receives a temp-table from another procedure using theOUTPUT TABLE-HANDLEform, then the receiving procedure must delete its copy of the temp-table after it is done with it.As with other dynamic objects, Progress does not know when you are done with a dynamic copy of a temp-table and therefore cannot delete it for you. You cannot allocate a temp-table to a widget pool, so this mechanism does not help you out. The temp-table is created in the
SESSIONwidget pool and therefore stays there until it’s deleted or until the session ends. Because a temp-table is normally a much larger object than a dynamic button, query, or buffer, it is critically important that you delete temp-tables when you’re done with them. If you’re done with the data in the temp-table but need to use the table again, then use theEMPTY-TEMP-TABLEmethod on the table handle to remove the data. Delete the table itself using theDELETE OBJECTstatement when you are done with it altogether.Because dynamic temp-tables are allocated in the
SESSIONpool, you can locate them through theSESSIONhandle’s buffer chain. If the buffer has a validTABLE-HANDLEattribute, then it’s a temp-table buffer and itsTABLE-HANDLEpoints to the temp-table itself:
Using the NUM-REFERENCES attribute
Starting with OpenEdge Release 10.1A, before you delete a procedure, you can use the
NUM-REFERENCESattribute to determine whether a temp-table is serving as a reference for other temp-tables in some other procedure. This is particularly helpful when you pass temp-tables as parameters with theBINDkeyword. Use this syntax:
If the temp-table has no other temp-table definitions currently referencing it, the
NUM-REFERENCESattribute returns 0. If one or more temp-tables are still being used by another temp-table, thenNUM-REFERENCESreturns the number of referring temp-tables.You can also use
NUM-REFERENCESto debug any memory leaks that occur when a persistent procedure closes.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |